from . import (
    CSVFormatter,
    DOCXFormatter,
    EXCELFormatter,
    PDFFormatter,
    TXTFormatter,
    FormatterInterface,
)

from ..exception import TypeMismatchException


class FormatterFactory:
    _type_mapping = {
        "csv": CSVFormatter,
        "docx": DOCXFormatter,
        "excel": EXCELFormatter,
        "pdf": PDFFormatter,
        "txt": TXTFormatter,
    }

    @classmethod
    def create(cls, file_type: str) -> FormatterInterface:
        if file_type not in cls._type_mapping:
            raise TypeMismatchException(cls._type_mapping.keys(), file_type)
        return cls._type_mapping[file_type]()
